 <?php
 
 //establecer una variable conratafisica $_LOCALHOST
$ruta=$_SERVER['DOCUMENT_ROOT']."/viventura"."/MDTour";
include_once("$ruta/star.php");
include_once("$ruta/MDTourGeneral/CDrawPageReg.php");
//include_once("$rut/conf/CConfig.php");


/** Datos del paquete-tour  */
 
if (!isset($_POST['guide1'])) {$_POST['guide1'] = "NULL"; }
if (!isset($_POST['guide2'])) {$_POST['guide2'] = "NULL"; }
if (!isset($_GET['codigo'])) {$_GET['codigo'] = "NULL"; }

$guide1 = $_POST['guide1'];
$guide2 = $_POST['guide2'];
$codigo =$_GET['codigo'];

echo $guide1;
echo $guide2;

$guides[0] = "";$guides[1] = "";$i=0;
$guidetc = "select guidetc_idGuide from pack_has_tour_has_guidetc where pack_has_tour_idPackTour = '$codigo'";
$answer = CModelo::getInstance()->getData($guidetc);

foreach($answer as $r => $c){
    $answer2 = $c;
    foreach($answer2 as $r2=> $c2){
        $guides[$i] = $c2;
        $i = $i+1;
    }
}


if($guides[0]==""){
    if($guide1!=""){
        
        $gui1 = "insert into pack_has_tour_has_guidetc (idPackTourGui,guidetc_idGuide,SerFlag,NumGui,pack_has_tour_idPackTour) values (NULL,'$guide1','0','1','$codigo')";
        $ans1 = CModelo::getInstance()->insertData($gui1);}
    if($guide2!=""){
        $gui2 = "insert into pack_has_tour_has_guidetc (idPackTourGui,guidetc_idGuide,SerFlag,NumGui,pack_has_tour_idPackTour) values (NULL,'$guide2','0','2','$codigo')";
        $ans2 = CModelo::getInstance()->insertData($gui2);}       
    }
else{
    //// un update que inhabilite guides en caso de ser distintos con los ingresados, luego ver el historial de cambios
}
 
?>